package com.login;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.database.DataCon;

public class LoginAction {
    String tableName="userInfo";
	String sqlstr;
	String rsString;
    Connection con=null;
	Statement stmt2=null;
	ResultSet rs=null;
	DataCon dt= new DataCon();
	
	
	public LoginAction(){}
	
	public String LoginAction(String name,String pass) throws SQLException{
		con = dt.DbConn();
		stmt2 = con.createStatement();  
		sqlstr = "select * from "+ tableName;
		System.out.println(sqlstr);
		System.out.println("name:"+name);
		System.out.println("pass" +pass);
		rs = stmt2.executeQuery(sqlstr);
		while(rs.next()){
			if(rs.getString("usrName").equals(name)&&rs.getString("usrPass").equals(pass)){
				rsString="1";
				break;
			}else{
				rsString="2";
			}
		}
		return rsString;
	}

}
